﻿using System.Linq;
using Schema.Things;

namespace Schema
{
    public static class Model
    {
        public static readonly AdministrativeArea AdministrativeArea = CreateAdministrativeArea();
        public static readonly ContactPoint ContactPoint = CreateContactPoint();
        public static readonly Country Country = CreateCountry();
        public static readonly CreativeWork CreativeWork = CreateCreativeWork();
        public static readonly Duration Duration = CreateDuration();
        public static readonly Event Event = CreateEvent();
        public static readonly MediaObject MediaObject = CreateMediaObject();
        public static readonly Movie Movie = CreatCreatMovie();
        public static readonly MusicRecording MusicRecording = CreateCreatMusicRecording();
        public static readonly Organization Organization = CreateOrganization();
        public static readonly Person Person = CreatePerson();
        public static readonly Place Place = CreatePlace();
        public static readonly PostalAddress PostalAddress = CreatePostalAddress();
        public static readonly Reservation Reservation = CreateReservation();
        public static readonly Thing Thing = CreateThing();

        private static AdministrativeArea CreateAdministrativeArea()
        {
            return new AdministrativeArea();
        }

        private static ContactPoint CreateContactPoint()
        {
            return new ContactPoint();
        }

        private static Country CreateCountry()
        {
            return new Country();
        }

        private static CreativeWork CreateCreativeWork()
        {
            return new CreativeWork();
        }

        private static Duration CreateDuration()
        {
            return new Duration();
        }

        private static Event CreateEvent()
        {
            return new Event();
        }

        private static MediaObject CreateMediaObject()
        {
            return new MediaObject();
        }

        private static Movie CreatCreatMovie()
        {
            return new Movie();
        }

        private static MusicRecording CreateCreatMusicRecording()
        {
            return new MusicRecording();
        }

        private static Organization CreateOrganization()
        {
            return new Organization();
        }

        private static Person CreatePerson()
        {
            return new Person();
        }

        private static Place CreatePlace()
        {
            return new Place();
        }

        private static PostalAddress CreatePostalAddress()
        {
            return new PostalAddress();
        }

        private static Reservation CreateReservation()
        {
            return new Reservation();
        }

        private static Thing CreateThing()
        {
            var alternateName = new Property("alternateName", ExpectedType.Text, "An alias for the item.");
            var description = new Property("description", ExpectedType.Text, "A short description of the item.");
            var name = new Property("name", ExpectedType.Text, "The name of the item.");
            var sameAs = new Property("sameAs", ExpectedType.URL, "URL of a reference Web page that unambiguously indicates the item's identity. E.g. the URL of the item's Wikipedia page, Freebase page, or official website.");
            var url = new Property("name", ExpectedType.URL, "URL of the item.");
            return new Thing(alternateName, description, name, sameAs, url);
        }

        public static Thing[] GetSupportedThings()
        {
            return new[]
            {
                AdministrativeArea,
                ContactPoint,
                Country,
                CreativeWork,
                Duration,
                Event,
                MediaObject,
                Movie,
                MusicRecording,
                Organization,
                Person,
                Place,
                PostalAddress,
                Reservation,
                Thing
            };
        }

        public static string[] GetSupportedThingsNames()
        {
            var things = GetSupportedThings();
            return things.Select(x => x.GetType().Name).ToArray();
        }

        public static Property[] GetSupportedProperties(Thing thing)
        {
            return thing.Properties.ToArray();
        }
    }
}